<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>Hello MUI</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<!--标准mui.css-->
		<link rel="stylesheet" href="css/mui.min.css">
		<link rel="stylesheet" type="text/css" href="css/icons-extra.css" />
		<style>
			html,
			body,
			.mui-content {
				height: 0px;
				margin: 0px;
				background-color: #efeff4;
			}
			
			.btnC {
				font-size: 16px;
				padding: 8px;
				margin: 2px;
			}
			
			
		</style>
	</head>

	<body>

		<header class="mui-bar mui-bar-nav">
			<a href="note.html" class="mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">新增便签</h1>
			<button id='send' class=" btnC  mui-btn-primary mui-pull-right" disabled="true">提交</button>
		</header>
		<div class="mui-content">
			<div class="mui-input-row">
				<textarea id="content" rows="20" placeholder="记录这一刻..."></textarea>
			</div>
		</div>
	</body>
	<script src="js/mui.min.js"></script>
	<script>
		var createBy = localStorage.getItem("employeeid");
		//提交表单数据
		var mcontent = document.getElementById("content");
		var mbutton = document.getElementById("send");
		mcontent.addEventListener('input', function() {
			mbutton.disabled = false;
			if(mcontent.value.length == 0) {
				mbutton.disabled = true;
			}
		});
		mbutton.addEventListener("click", function() {
			var content=mcontent.value;
			var network = true;
			if(mui.os.plus) {
				mui.plusReady(function() {
					if(plus.networkinfo.getCurrentType() == plus.networkinfo.CONNECTION_NONE) {
						network = false;
					}
				});
			}
			if(network) {
				console.log('网络正常,正在发送请求...');
				mui.ajax({
					url: 'http://113.71.26.27:8080/tpl/function/insertnote',
					async: true,
					type: 'post',
					timeout: 2000,
					data: {
						createBy: createBy,
						content: content
					},
					dataType: "text",
					success: function(data) {
						if(data == "1") {
							//列表页面
							window.location.href = "note.html";
						}
					}

				});
			} else {
				mui.toast("当前网络不给力，请稍后再试...");
			}
		});

		/**
		 * 重写返回事件
		 */
		mui.back = function() {

			window.location.href = "note.html";
		}
	</script>

</html>